<template>
    <div>
        <header class="pr white" style="padding: 45px 0px 40px;">
            <img src="../../assets/images/7.jpg" class="displayB centerauto shadowB" style="max-width: 70%;margin: 0px auto;padding: 10px;background: #fff;" />
        </header>
        <van-cell-group>
            <van-field label="原支付密码：" type="password" maxlength="6" v-model="oldpassword" placeholder="请输入原支付密码" />
            <van-field label="新支付密码：" type="password" maxlength="6" v-model="password" placeholder="请输入新支付密码" />
            <van-field label="确认密码：" type="password" maxlength="6" v-model="confirm_password" placeholder="再次输入密码" />
        </van-cell-group>
        <div class="text-center margin_t50">
            <van-button type="primary" class="width_80p btn_size_40" @click="submit">确 定</van-button>
        </div>
    </div>
</template>
<script>

    import '@/assets/css/main.css'
    export default {
        data(){
            return{
                oldpassword: '',
                password: '',
                confirm_password: '',
            }
        },
        methods: {
            submit(){

                var _this = this;
                if(!_this.oldpassword){
                    _this.$toast('请输入原密码');
                    return;
                }
                if(!_this.password){
                    _this.$toast('请输入新密码');
                    return;
                }
                if(!_this.confirm_password){
                    _this.$toast('请输入确认密码');
                    return;
                }
                if(_this.password != _this.confirm_password){
                    _this.$toast('两次密码不一致');
                    return;
                }

                this.$httpPost('/api/index/Personal_center/updatePassword',{
                    'u_id': window.localStorage.u_id,
                    'oldpassword': _this.oldpassword,
                    'password': _this.password,
                    'confirm_password': _this.confirm_password,
                    'type': 2,
                }).then(response => {
                    
                    if(response.code == 200){

                        _this.$toast(response.msg);

                        setTimeout(() => {
                            _this.$router.push({path:'/home'});
                        }, 2000);

                    }else{
                        
                        _this.$toast(response.msg);
                    }

                });
            },
        },
        mounted(){
            
        },
    }
</script>